
/** 
  * @brief itol 和单位换算
  */

#include <stdlib.h>
#include <stdio.h>
#include <string>

const char* itos(int num)
{
	float f = 0.0f;
	char* str = new char[16];
	if(num > 100000000)
	{
		f = static_cast<float>(num) / 100000000;
		sprintf(str,"%.3f亿",f);
		return str;
	}
	if(num > 10000)
	{
		f = static_cast<float>(num) / 10000;
		sprintf(str,"%.2f万",f);
		return str;
	}
	
	sprintf(str,"%d",num);
	return str;
}



int main(void)
{
    long l;
    char *str = "98765432";
    l = atol(str); /* 原来为l = atol(str); */
    printf("string = %s integer = %ld\n", str, l);


	float f = 1.3333333333333333333;
	
	printf("float: %.3f\n",f);

	printf("itos: %s\n",itos(1111111111));

    return(0);
}
